package com.happyass.show.dao;

import com.happyass.show.entity.Addr;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * TODO
 *
 * @author admin
 * @date 2021/1/6 11:45
 *
 * <P></P>
 **/

@Repository
public interface AddrDao extends PagingAndSortingRepository<Addr,Integer>, JpaRepository<Addr,Integer> {
    //自定义sql查询
    @Transactional
    @Modifying(clearAutomatically = true)//修改数据的时候，同时清除实体的数据
    //nativeQuery=true，支持原生sql，nativeQuery=false，支持hql      :userName,对应的是@Param的值
    @Query(value = "select * from addr where not addr_name = :activityAddr",nativeQuery = true)
    List<Addr> selectWithoutAddr(@Param("activityAddr") String activityAddr);

    Addr findByAddrName(String activityAddr);
}
